/*
 * Copyright (c) 2011-2014, fortiss GmbH.
 * Licensed under the Apache License, Version 2.0.
 *
 * Use, modification and distribution are subject to the terms specified
 * in the accompanying license file LICENSE.txt located at the root directory
 * of this software distribution. A copy is available at
 * http://chromosome.fortiss.org/.
 *
 * This file is part of CHROMOSOME.
 *
 * $Id: plugAndPlayManagerComponentWrapper.h 7837 2014-03-14 12:33:13Z wiesmueller $
 */

/**
 * \file
 *         Component wrapper - implements interface of a component
 *              to the data handler
 *
 * \author
 *         This file has been generated by the CHROMOSOME Modeling Tool (XMT)
 *         (fortiss GmbH).
 */

#ifndef XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_H
#define XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_H

/******************************************************************************/
/***   Includes                                                             ***/
/******************************************************************************/
#include "xme/core/executionManager/include/executionManagerDataStructures.h"

#include "xme/core/topicData.h"

/******************************************************************************/
/***   Type definitions                                                     ***/
/******************************************************************************/

/**
 * \enum xme_core_pnp_pnpManagerComponentWrapper_internalFunctionId_e
 *
 * \brief Values for identifying functions of pnpManager component.
 */
enum xme_core_pnp_pnpManagerComponentWrapper_internalFunctionId_e
{
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_FUNCTION_PNPMANAGERGENERATERUNTIMEGRAPHS = 0, ///< Function 'pnpManagerGenerateRuntimeGraphs'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_FUNCTION_PNPMANAGERPROCESSLOGINREGISTRATION = 1, ///< Function 'pnpManagerProcessLoginRegistration'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_FUNCTION_PNPMANAGERPROCESSLOGOUTREQUESTS = 2, ///< Function 'pnpManagerProcessLogoutRequests'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_FUNCTION_PNPMANAGERPROCESSLOGOUTACKNOWLEDGMENTS = 3, ///< Function 'pnpManagerProcessLogoutAcknowledgments'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_FUNCTION_PNPMANAGERPROCESSREMOVECOMPONENTREQUEST = 4  ///< Function 'pnpManagerProcessRemoveComponentRequest'
};

/**
 * \enum xme_core_pnp_pnpManagerComponentWrapper_internalPortId_e
 *
 * \brief Values for xme_core_pnp_pnpManagerComponentWrapper_internalPortId_t.
 */
enum xme_core_pnp_pnpManagerComponentWrapper_internalPortId_e
{
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_PORT_INCOMPONENTINSTANCEMANIFEST = 0, ///< Port 'inComponentInstanceManifest'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_PORT_INPNPLOGINREQUEST = 1, ///< Port 'inPnPLoginRequest'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_PORT_INLOGOUTREQUEST = 2, ///< Port 'inLogoutRequest'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_PORT_INLOGOUTACKNOWLEDGMENT = 3, ///< Port 'inLogoutAcknowledgment'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_PORT_INREMOVECOMPONENTREQUEST = 4, ///< Port 'inRemoveComponentRequest'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_PORT_OUTRUNTIMEGRAPH = 5, ///< Port 'outRuntimeGraph'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_PORT_OUTPNPLOGINRESPONSE = 6, ///< Port 'outPnPLoginResponse'
    XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_PORT_OUTLOGOUTNOTIFICATION = 7  ///< Port 'outLogoutNotification'
};

/**
 * \typedef xme_core_pnp_pnpManagerComponentWrapper_internalPortId_t
 *
 * \brief Defines internal port ids of component 'pnpManager'.
 *
 * \details These can be used when calling the xme_core_pnp_pnpManagerComponentWrapper_receivePort function.
 *          For the definition of possible values, see enum xme_core_pnp_pnpManagerComponentWrapper_internalPortId_e.
 */
typedef uint8_t xme_core_pnp_pnpManagerComponentWrapper_internalPortId_t;

/******************************************************************************/
/***   Prototypes                                                           ***/
/******************************************************************************/
XME_EXTERN_C_BEGIN

/**
 * \brief Initializes this component wrapper.
 *
 * \retval XME_STATUS_SUCCESS on success.
 */
xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_init(void);

/**
 * \brief Finalizes this component wrapper.
 */
void
xme_core_pnp_pnpManagerComponentWrapper_fini(void);

/**
 * \brief Associate an internal port number with the corresponding port handle.
 *        For the ids of the individual ports, see the definition of xme_core_pnp_pnpManagerComponentWrapper_internalPortId_t.
 *
 * \param dataPacketId Port handle from the dataHandler.
 * \param componentInternalPortId Component internal port number of the above port.
 *
 * \retval XME_STATUS_SUCCESS if no problems occurred.
 * \retval XME_STATUS_INVALID_PARAMETER if componentInternalPortId is unknown.
 */
xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_receivePort
(
    xme_core_dataManager_dataPacketId_t dataPacketId,
    xme_core_pnp_pnpManagerComponentWrapper_internalPortId_t componentInternalPortId
);

/**
 * \brief This function is called by the function wrapper after the step
 *        function has been called. It signals to the middleware that all
 *        input ports have been read.
 */
void
xme_core_pnp_pnpManagerComponentWrapper_completeReadOperations(void);

/**
 * \brief This function is called by the function wrapper after the step
 *        function has been called. It signals to the middleware that all
 *        write operations on ports that actually have been written to
 *        in the step function (via the functions in this component wrapper)
 *        are now completed.
 */
void
xme_core_pnp_pnpManagerComponentWrapper_completeWriteOperations(void);

/**
 * \brief Read data from port 'inComponentInstanceManifest'.
 *
 * \details Port description:
 *            The component instance manifest contains all the information about a joining node with the declaration of all components that this node wants to start and connect to CHROMOSOME network. 
 *
 * \param[out] data User provided storage, to which the data is copied.
 *
 * \retval XME_STATUS_SUCCESS if reading was successful.
 * \retval XME_STATUS_NO_SUCH_VALUE when there is now new data on this port
 *         (only possible when this port is an optional port of the current function).
 * \retval XME_STATUS_INVALID_PARAMETER if data is NULL.
 * \retval XME_STATUS_INTERNAL_ERROR in case of any other error.
 */
xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_readPortInComponentInstanceManifest
(
    const xme_core_topic_pnp_componentInstanceManifest_t* data
);

/**
 * \brief Read data from port 'inPnPLoginRequest'.
 *
 * \details Port description:
 *            This subscription listens to login manager requests for node registration. 
 *
 * \param[out] data User provided storage, to which the data is copied.
 *
 * \retval XME_STATUS_SUCCESS if reading was successful.
 * \retval XME_STATUS_NO_SUCH_VALUE when there is now new data on this port
 *         (only possible when this port is an optional port of the current function).
 * \retval XME_STATUS_INVALID_PARAMETER if data is NULL.
 * \retval XME_STATUS_INTERNAL_ERROR in case of any other error.
 */
xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_readPortInPnPLoginRequest
(
    const xme_core_topic_login_pnpLoginRequest_t* data
);

/**
 * \brief Read data from port 'inLogoutRequest'.
 *
 * \param[out] data User provided storage, to which the data is copied.
 *
 * \retval XME_STATUS_SUCCESS if reading was successful.
 * \retval XME_STATUS_NO_SUCH_VALUE when there is now new data on this port
 *         (only possible when this port is an optional port of the current function).
 * \retval XME_STATUS_INVALID_PARAMETER if data is NULL.
 * \retval XME_STATUS_INTERNAL_ERROR in case of any other error.
 */
xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_readPortInLogoutRequest
(
    const xme_core_topic_pnp_logoutRequest_t* data
);

/**
 * \brief Read data from port 'inLogoutAcknowledgment'.
 *
 * \param[out] data User provided storage, to which the data is copied.
 *
 * \retval XME_STATUS_SUCCESS if reading was successful.
 * \retval XME_STATUS_NO_SUCH_VALUE when there is now new data on this port
 *         (only possible when this port is an optional port of the current function).
 * \retval XME_STATUS_INVALID_PARAMETER if data is NULL.
 * \retval XME_STATUS_INTERNAL_ERROR in case of any other error.
 */
xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_readPortInLogoutAcknowledgment
(
    const xme_core_topic_pnp_logoutAcknowledgment_t* data
);

/**
 * \brief Read data from port 'inRemoveComponentRequest'.
 *
 * \param[out] data User provided storage, to which the data is copied.
 *
 * \retval XME_STATUS_SUCCESS if reading was successful.
 * \retval XME_STATUS_NO_SUCH_VALUE when there is now new data on this port
 *         (only possible when this port is an optional port of the current function).
 * \retval XME_STATUS_INVALID_PARAMETER if data is NULL.
 * \retval XME_STATUS_INTERNAL_ERROR in case of any other error.
 */
xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_readPortInRemoveComponentRequest
(
    const xme_core_topic_pnp_removeComponentRequest_t* data
);

/**
 * \brief Write data to port 'outRuntimeGraph'.
 *
 * \details Port description:
 *          The runtime graph out is the runtime graph produced by the plug and play manager. 
 *          This graph contains the required physical networking information required for configuring a node using the plug and play infrastructure.
 *
 * \note The write operation is only allowed to be called once per
 *       data packet sending process. A data packet is sent 
 *       as soon as the xme_core_pnp_pnpManagerComponentWrapper_writeNextPacket()
 *       function is being called or when the step function
 *       returns and data have been written.
 * 
 * \param[in] data User provided storage, from which the data is copied.
 *            When NULL no data will be written to the port (this
 *            is also treated as  success).
 *
 * \retval XME_STATUS_SUCCESS if operation was successful.
 */
xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_writePortOutRuntimeGraph
(
    const xme_core_topic_pnpManager_runtime_graph_model_t* const data
);

/**
 * \brief Write data to port 'outPnPLoginResponse'.
 *
 * \details Port description:
 *          This publication exposes the data needed to connect remote nodes to the plug and play manager.
 *
 * \note The write operation is only allowed to be called once per
 *       data packet sending process. A data packet is sent 
 *       as soon as the xme_core_pnp_pnpManagerComponentWrapper_writeNextPacket()
 *       function is being called or when the step function
 *       returns and data have been written.
 * 
 * \param[in] data User provided storage, from which the data is copied.
 *            When NULL no data will be written to the port (this
 *            is also treated as  success).
 *
 * \retval XME_STATUS_SUCCESS if operation was successful.
 */
xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_writePortOutPnPLoginResponse
(
    const xme_core_topic_login_pnpLoginResponse_t* const data
);

/**
 * \brief Write data to port 'outLogoutNotification'.
 *
 * \details Port description:
 *          Sends a notification to the loginManager about a successful logout of a node.
 *
 * \note The write operation is only allowed to be called once per
 *       data packet sending process. A data packet is sent 
 *       as soon as the xme_core_pnp_pnpManagerComponentWrapper_writeNextPacket()
 *       function is being called or when the step function
 *       returns and data have been written.
 * 
 * \param[in] data User provided storage, from which the data is copied.
 *            When NULL no data will be written to the port (this
 *            is also treated as  success).
 *
 * \retval XME_STATUS_SUCCESS if operation was successful.
 */
xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_writePortOutLogoutNotification
(
    const xme_core_topic_pnp_logoutNotification_t* const data
);

xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_readInputPortAttribute
(
    xme_core_pnp_pnpManagerComponentWrapper_internalPortId_t portId,
    xme_core_attribute_key_t attributeKey,
    void* const buffer,
    uint32_t bufferSize
);

xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_writeOutputPortAttribute
(
    xme_core_pnp_pnpManagerComponentWrapper_internalPortId_t portId,
    xme_core_attribute_key_t attributeKey,
    const void* const buffer,
    uint32_t bufferSize
);

xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_readNextPacket
(
    xme_core_pnp_pnpManagerComponentWrapper_internalPortId_t portId
);

xme_status_t
xme_core_pnp_pnpManagerComponentWrapper_writeNextPacket
(
    xme_core_pnp_pnpManagerComponentWrapper_internalPortId_t portId
);


XME_EXTERN_C_END

#endif // #ifndef XME_CORE_PNP_PNPMANAGERCOMPONENTWRAPPER_H
